<? 
class kalenderController extends inabuurt_controller_action{
	
	protected function init(){
				$this -> view -> addStyle(view::PATH_TO_STYLE.'kalender.css');

		
	
	}
	
	public function indexAction(){
		
			if($this -> request -> getParam(0) == NULL || $this -> request -> getParam(0) > 2109 || $this -> request -> getParam(0) < 2008){
		
			$jaar = date('o');
		
		
		}else{
		
			$jaar = $this -> request -> getParam(0);
		
		}
		
		if($this -> request -> getParam(1) == NULL || $this -> request -> getParam(1) > 12 || $this -> request -> getParam(1) < 1){
		
			$maand = date('n');
		
		}else{
		
			$maand = $this -> request -> getParam(1);
		
		}

		
		
		
		
		
		
		
		
		
		
		$this -> view -> setTpl('kalender.php');
	
		$kalender = new kalender($this -> conn);
		$kalender -> setJaar($jaar);
		
		
		
		$this -> view -> dagen = $kalender -> getMaand($maand) -> getDagen();
	
	
	
		if($maand == 12){
			if($jaar + 1 < 2109){
		
		
			$this -> view -> nextPage = '/kalender/' .( $jaar + 1) . '/1/';
			$this -> view -> nextPageName = 'Januari'; 
			
			}
		
		}else{
			$this -> view -> nextPage = '/kalender/' . $jaar . '/' . ($maand + 1) .'/';
			$this -> view -> nextPageName = $kalender -> getMaand($maand +1) -> getNaam(); 
		
		} 
		
		if($maand == 1){
			if($jaar - 1 > 2008){
		
		
			$this -> view -> prevPage = '/kalender/' . ($jaar - 1 ). '/12/';
			$this -> view -> prevPageName = 'December'; 
			
			}
		
		}else{
		
			$this -> view -> prevPage = '/kalender/' . $jaar . '/' . ($maand - 1) . '/ ';
			$this -> view -> prevPageName = $kalender -> getMaand($maand - 1) -> getNaam(); 
		}
	
	
		$this -> view -> infoText = $kalender -> getMaand($maand) -> getNaam() . ' / ' . $jaar; 
		$this -> view -> render();
		
		
	
	
	}


	public function activiteitenAction(){
	
		$this -> view -> setTpl('activiteiten.php');
		$crumbs = $this -> view -> breadcrumb;
	
		if($this -> request -> getParam(0) == NULL || $this -> request -> getParam(0) > 2109 || $this -> request -> getParam(0) < 2008){
			
				$this -> view -> error = "error";
				$this -> view -> render();
				die();
		}
			
		if($this -> request -> getParam(1) == NULL || $this -> request -> getParam(1) > 12 || $this -> request -> getParam(1) < 1){
			
				$this -> view -> error = "error";
				$this -> view -> render();
				die();
			
		}
		
		
		$kalender = new kalender($this -> conn);
		$kalender -> setJaar($this -> request -> getParam(0));
		
		
		if($this -> request -> getParam(2) == NULL || $this -> request -> getParam(2) >  $kalender -> getMaand($this -> request -> getParam(1)) -> aantalDagen() || $this -> request -> getParam(2) < 1){
			
				$this -> view -> error = "error";
				$this -> view -> render();
				die();
			
		}
		
		
		$dag = $kalender -> getMaand($this -> request -> getParam(1)) -> getDag($this -> request -> getParam(2));
		
		$activities = $dag -> getActivities();
		
		$this -> view -> activi = $activities;
		$this -> view -> dag = $dag -> getNaam();
		$this -> view -> datum = $dag -> getNummer() . '/' . $dag -> getMaand() . '/' . $dag -> getJaar();
		$this -> view -> backLink =  '/kalender/' . $dag -> getJaar() . '/' . $dag -> getMaand();
		
		
		$crumbs[] = array($dag -> getNaam() . ' '. $this -> view -> datum,'');
		
		$this -> view -> breadcrumb = $crumbs;
		
		$this -> view -> render();
	
	}

	
	
	
	
}


?>